package com.nmgsr.ptmsapp.activity;

import android.content.Intent;
import android.view.View;
import android.widget.ImageView;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentStatePagerAdapter;
import androidx.viewpager.widget.ViewPager;

import com.nmgsr.nettools.base.BaseActivity;
import com.nmgsr.ptmsapp.R;
import com.nmgsr.ptmsapp.adapter.FragmentAdapter;
import com.nmgsr.ptmsapp.fragment.HomeFragment;
import com.nmgsr.ptmsapp.fragment.MyFragment;
import com.yinglan.alphatabs.AlphaTabsIndicator;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends BaseActivity {
    private ImageView centerButton;
    @Override
    protected int getLayoutId() {
        return R.layout.main_activity;
    }

    @Override
    protected void initView() {
        view_status_bar.setVisibility(View.VISIBLE);
        fl_actionbar.setVisibility(View.GONE);
        AlphaTabsIndicator alphaIndicator = findViewById(R.id.alphaIndicator);
        ViewPager viewPager = findViewById(R.id.viewPager);

        List<Fragment> fragments = new ArrayList<>();
        fragments.add(new HomeFragment());
        fragments.add(new MyFragment());
        FragmentAdapter fragmentAdapter = new FragmentAdapter(getSupportFragmentManager(),
                FragmentStatePagerAdapter.BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT, fragments);

        viewPager.setAdapter(fragmentAdapter);
        viewPager.addOnPageChangeListener(fragmentAdapter);
        alphaIndicator.setViewPager(viewPager);
        centerButton = findViewById(R.id.centerButton);
        centerButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this, QRCodeScannerActivity.class);
                startActivity(intent);
            }
        });
    }
}
